<?php

use think\migration\Migrator;
use think\migration\db\Column;

class OperateLog extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('operate_log', ['comment' => '操作日志表']);
        $table
            ->addColumn('title', 'string',array('limit' => 120,'null'=>true,'comment' => '日志标题'))
            ->addColumn('admin_id', 'integer',array('limit' => 30, 'comment' => '操作人员id'))
            ->addColumn('username', 'string',array('limit' => 20, 'comment' => '管理员名字'))
            ->addColumn('url', 'string',array('limit' => 1500,'null'=>true,'comment' => '操作页面'))
            ->addColumn('collect_id', 'integer',array('limit' => 20,'null'=>true,'comment' => '采集id'))
            ->addColumn('type', 'integer',array('limit' => 20,'null'=>true,'comment' => '类型(1.采集案件，2，采集审核案件，3，整改案件，4.审核整改案件，5.延期,6/延期审核，7.退回，8退回审核，9交办，10，交办审核)'))
            ->addColumn('ip', 'string',array('limit' => 50,'null'=>true, 'comment' => 'IP'))
            ->addColumn('useragent', 'string',array('limit' => 255,'null'=>true, 'comment' => 'User-Agent'))
            ->addTimestamps()
            ->addSoftDelete()
            ->addIndex(array('username'))
            ->create();
    }
}
